Perl DBI Examples
Revision as of 18:50, 30 April 2008 by PeterHarding (talk | contribs) (New page: =Examples= <pre> #!/usr/bin/env perl use DBI; # Open the database my ($DSN,$dbh,$sth); $dbh = DBI->connect("dbi??={SQL Server};Server=$db_instance;Database=$db_name;UID=$db_user;PWD=$...)
Examples
#!/usr/bin/env perl use DBI; # Open the database my ($DSN,$dbh,$sth); $dbh = DBI->connect("dbi??={SQL Server};Server=$db_instance;Database=$db_name;UID=$db_user;PWD=$db_pass") or croak "$DBI::errstr\n"; # Get the patch names & store them in @files my (@rows,@files,$key,$value); my $sql = "select patch from computervulnerability where detected=0"; $sth = $dbh->prepare($sql) or die "$DBI::errstr\n"; $sth->execute or die "$DBI::errstr\n"; while (@rows = $sth->fetchrow_array()) { push(@files,$rows[0]); } # Close the database $dbh->disconnect;