dbi

Perl DBI without accessing the database

…衆ロ難τιáo~ 提交于 2019-12-01 17:46:34
问题 I'm creating a set of SQL INSERT statements for a database that doesn't exist yet, and I'm saving them to file. How can I use Perl's powerful DBI module to create those INSERT statements without accessing a specific database. In particular, it looks like using the $dbh->quote() function requires that I instantiate $dbh with a connection to a database. 回答1: Unfortunately, the actual quote() behaviour isn't always a portable characteristic, so each driver will do them differently. Unless you

Why does Perl's DBI complain about “failed: ERROR OCIEnvNlsCreate” when I try to connect to Oracle 11g?

泄露秘密 提交于 2019-12-01 06:28:00
I am getting the following error connecting to an Oracle 11g database using a simple Perl script: failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH (Windows) and or NLS settings, permissions, etc. at The script is as follows: #!/usr/local/bin/perl use strict; use DBI; if ($#ARGV < 3) { print "Usage: perl testDbAccess.pl dataBaseUser dataBasePassword SID dataBasePort\n"; exit 0; } my ($user, $pwd, $sid, $port) = @ARGV; my $host = `hostname`; my $dbh; my $sth; my $dbname = "dbi:Oracle:HOST=$host;SID=$sid;PORT=$port"; openDbConnection(); closeDbConnection(); sub

Why does Perl's DBI complain about “failed: ERROR OCIEnvNlsCreate” when I try to connect to Oracle 11g?

与世无争的帅哥 提交于 2019-12-01 03:26:50
问题 I am getting the following error connecting to an Oracle 11g database using a simple Perl script: failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH (Windows) and or NLS settings, permissions, etc. at The script is as follows: #!/usr/local/bin/perl use strict; use DBI; if ($#ARGV < 3) { print "Usage: perl testDbAccess.pl dataBaseUser dataBasePassword SID dataBasePort\n"; exit 0; } my ($user, $pwd, $sid, $port) = @ARGV; my $host = `hostname`; my $dbh; my $sth; my $dbname

%ENV doesn't work and I cannot use shared library

故事扮演 提交于 2019-12-01 03:16:37
I cannot use %ENV var on my Perl script to use Oracle libs. BEGIN { $ORACLE_HOME = "/usr/lib/oracle/10.2.0.3/client64"; $LD_LIBRARY_PATH = "$ORACLE_HOME/lib"; $ORACLE_SID="prod"; $ENV{ORACLE_SID}=$ORACLE_SID; $ENV{ORACLE_HOME}= $ORACLE_HOME; $ENV{LD_LIBRARY_PATH}= $LD_LIBRARY_PATH; }; If I print $ENV{'ORACLE_HOME'} and $ENV{'LD_LIBRARY_PATH'} all seems ok but, when I run my script I have the error: install_driver(Oracle) failed: Can't load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file: No such file or directory at

%ENV doesn't work and I cannot use shared library

那年仲夏 提交于 2019-11-30 23:44:46
问题 I cannot use %ENV var on my Perl script to use Oracle libs. BEGIN { $ORACLE_HOME = "/usr/lib/oracle/10.2.0.3/client64"; $LD_LIBRARY_PATH = "$ORACLE_HOME/lib"; $ORACLE_SID="prod"; $ENV{ORACLE_SID}=$ORACLE_SID; $ENV{ORACLE_HOME}= $ORACLE_HOME; $ENV{LD_LIBRARY_PATH}= $LD_LIBRARY_PATH; }; If I print $ENV{'ORACLE_HOME'} and $ENV{'LD_LIBRARY_PATH'} all seems ok but, when I run my script I have the error: install_driver(Oracle) failed: Can't load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so'

Is MySQL more resistant to SQL injection attack than PostgreSQL (under Perl/DBI)?

怎甘沉沦 提交于 2019-11-30 23:23:51
I am reviewing a Linux based perl web application that contains a login handler with the ubiquitous my $sth = $DB->prepare("SELECT password from passwords where userid='$userid'") or die; $sth->execute or die; ... where $userid is initialized from (unsafe, unfiltered) web user input. It is well known that the DBI documentation recommends that this code should be changed to use the placeholder "?" in place of '$userid' for security. This code was isolated on an off network box, as-is, for the purpose of a security review. Code like this on an internet server will eventually be cracked as there

Perl DBI insert multiple rows using mysql native multiple insert ability

一笑奈何 提交于 2019-11-30 17:47:34
Has anyone seen a DBI-type module for Perl which capitalizes, easily, on MySQL's multi-insert syntax insert into TBL (col1, col2, col3) values (1,2,3),(4,5,6),... ? I've not yet found an interface which allows me to do that. The only thing I HAVE found is looping through my array. This method seems a lot less optimal vs throwing everything into a single line and letting MySQL handle it. I've not found any documentation out there IE google which sheds light on this short of rolling my own code to do it. TIA There are two approaches. You can insert (?, ?, ?) a number of times based on the size

How to Install DBD::Oracle in Strawberry Perl

喜你入骨 提交于 2019-11-30 12:49:18
I am trying to install DBD::Oracle using the CPAN shell in Strawberry Perl. I initially experienced an error because the Makefile could not locate an OCI library, so I installed the instant client from Oracle. I thought this would fix the problem, but now I get a large mixture of errors and warnings from Oracle.h , dbdimp.h , Oracle.c , Oracle.xsi , and Oracle.xs . Any suggestions for how I should proceed? Is it possible that there is a problem with existing Oracle software on my computer? I am fairly new to Perl, so any help is appreciated. Edit -- I'm including the entire output below: cpan>

Dump prepared sql query from DBI statement in PERL

守給你的承諾、 提交于 2019-11-30 07:02:26
问题 im using DBI in Perl to connect to my PostgreSQL Database. Everything is working fine but in my debugging (printing results etc.) iam not able to see if the query prepared by perls DBI module is really correct. I have something like this: $sth->prepare( qq{SELECT * FROM company WHERE companyname LIKE ? AND city = ?}); $sth->execute( $name.'%', $city); Iam not able to see how the sql query looks after calling execute, as execute is the latest step where parameters are binded to the query. I

How can I show the query time in Perl, DBI?

拜拜、爱过 提交于 2019-11-30 03:28:28
问题 I use Perl and DBI to manage my MySQL tables, querys, etc. How can I show the running time of a query? If I do a SELECT in the console, the result will be like this: +-----+-------------+ | id | name | +-----+-------------- | 1 | Jack | | 2 | Joe | | 3 | Mary | +-----+-------------+ 3 rows in set (0.17 sec) I need to show 0.17 sec . There is any way in DBI to show the running time in Perl, something like this? my $dbh = $db->prepare("SELECT id, name FROM names ORDER BY id;"); $dbh->execute;