/[informatika.old]/to_csv.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /to_csv.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Wed Jun 14 09:42:59 2000 UTC revision 1.2 by dpavlin, Tue Jul 18 08:24:39 2000 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/perl -w  #!/usr/local/bin/perl -w
2    
3    # export e-mail adresa za Filipa,
4    # Usage:
5    #
6    # to_csv.pl [yyyy-mm-dd]
7    #
8    # yyyy-mm-dd ... datum od kojeg se vrši export (datum zadnjeg exporta)
9    
10  use DBI;  use DBI;
11    
12    my $sql_where;
13    
14    if (defined($ARGV[0])) {
15            $sql_where = " and datum_unesen > '$ARGV[0]'";
16    }
17    
18  my $mydbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;  my $mydbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;
19  $mysth = $mydbh->prepare("  $mysth = $mydbh->prepare("
20          select ime,prezime,alias||'\@pliva.hr' from osobe,e_mail where e_mail.osoba_id=osobe.id          select ime,prezime,alias||'\@pliva.hr' as email from osobe,e_mail where e_mail.osoba_id=osobe.id $sql_where
21          ") || die $mydbh->errstr();          ") || die $mydbh->errstr();
22  $mysth->execute() || die $mysth->errstr();  $mysth->execute() || die $mysth->errstr();
23    
24  print "#",join("\t",@{ $mysth->{NAME} }),"\n";  print "#",join(",",@{ $mysth->{NAME} }),"\n";
25  while (@myarr = $mysth->fetchrow_array() ) {  while (@myarr = $mysth->fetchrow_array() ) {
26          print join(",",@myarr),"\n";          print join(",",@myarr),"\n";
27  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26