dbi

DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)

拟墨画扇 提交于 2019-12-21 04:59:24
问题 I have included gems, dbd-mysql (0.4.4) dbi (0.4.5) mysql (2.8.1) on rails console when I run the following code, require 'rubygems' require "dbi" require 'dbd-mysql' dbh = DBI.connect("DBI:Mysql:TestDB:localhost","username", "pwd") 1.9.2-p180 :001 > require 'rubygems' => false 1.9.2-p180 :002 > require "dbi" => false 1.9.2p180 :003 > require 'dbd-mysql' LoadError: no such file to load -- dbd-mysql from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'

Querying multiple times in Oracle using perl returns only the first query

蹲街弑〆低调 提交于 2019-12-20 07:48:13
问题 Note: I have corrected the variable differences and it does print the query from the first set but it returns nothing from the second set. If I use the second set only it works. In the code below, I have some_array which is array of array the array contains text like name. So @some_array= ([sam, jon, july],[Mike, Han,Tommy],[angie, sita, lanny]); Now when I querying the list like 'sam jon july' first and 'mike han tommy' . Only the execute return the result from the first list others is undef

Win 64 Strawberry Perl DBI no error reporting bug still not fixed?

寵の児 提交于 2019-12-20 06:28:44
问题 Been dealing with this since 2011. Usually able to work around it. Now a situation has arisen where I really need to be able to handle errors, and I'm thinking, people have known about this problem for years, it seems like the sort of thing high up on the fix list, but the latest DBI upgrade and the problem still has not been resolved. Has anyone found a work-around, or know how to hack the libraries and get DBI::errstr to carry a value when there is an error? Here's my code (And yes I am

DBD::CSV and placeholders

不问归期 提交于 2019-12-20 02:34:25
问题 #!/usr/bin/env perl use warnings; use strict; use DBI; my $dbh = DBI->connect( "DBI:CSV:", '', '', { RaiseError => 1 } ) or die DBI->errstr; my $table = 'my_test_table_1.csv'; $dbh->do( "CREATE TEMP TABLE $table( id INTEGER, name CHAR(64) )" ); my $sth = $dbh->prepare( "INSERT INTO $table ( id, name ) VALUES( ?, ? )" ); $sth->execute( 1, 'Ruth' ); $sth->execute( 2, 'John' ); $sth->execute( 3, 'Nena' ); $sth->execute( 4, 'Mark' ); $sth = $dbh->prepare( "SELECT * FROM $table WHERE id > ? LIMIT

Why does DBI implicitly change integers to strings?

守給你的承諾、 提交于 2019-12-20 01:38:34
问题 I have a MySQL table with following structure. alid bigint(20), ndip varchar(20), ndregion varchar(20), occ_num int(3), Delta_Flag int(1) After selecting data from the table, I am getting all the data quoted and as a string value. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use FindBin; use lib $FindBin::Bin; use Database; my $pwd = $FindBin::Bin; my $db = Database->new( 'mysql', "$pwd/config.ini" ); my $db1 = Database->new( 'mysql', "$pwd/config2.ini" ); my @tables = qw(

Should I disconnect() if I'm using Apache::DBI's connect_cached()?

大憨熊 提交于 2019-12-19 12:06:00
问题 My mod_perl2-based intranet app uses DBI->connect_cached() which is supposedly overridden by Apache::DBI 's version of the same. It has normally worked quite well, but just recently we started having an issue on our testing server--which had only two users connected--whereby our app would sometimes, but not always, die when trying to reload a page with 'FATAL: sorry, too many clients already' connecting to our postgres 9.0 backend, despite all of them being <IDLE> if I look at the stats in

How can I export an Oracle table to tab separated values?

喜夏-厌秋 提交于 2019-12-18 09:06:16
问题 I need to export a table in the database to a tab separated values file. I am using DBI on Perl and SQL Plus. Does it support (DBI or SQL Plus) exporting and importing to or from TSV files? I can write a code to do my need, But I would like to use a ready made solution if it is available. 回答1: It should be relatively simple to dump a table to a file with tab-separated values. For example: open(my $outputFile, '>', 'myTable.tsv'); my $sth = $dbh->prepare('SELECT * FROM myTable'); $sth->execute

How can I fetch the last row I inserted using DBI?

南楼画角 提交于 2019-12-18 04:28:07
问题 How can I fetch the last row that was inserted using DBI (DBD::mysql)? Code sample: my $sth = $dbh->prepare('INSERT INTO a ( x, y, z ) VALUES ( ?, ?, ? )'); $sth->execute( $x, $y, $z ); How can I get access to the data that was inserted by the above prepare statement? I need to get the primary ID ( AUTOINCREMENT ) value. UPDATE: From DBD::mysql documentation: An alternative way for accessing this attribute is via $dbh->{'mysql_insertid'} . Thank you Manni and n0rd for your answers. :-) 回答1:

Perl DBI - run SQL Script with multiple statements

我的未来我决定 提交于 2019-12-17 14:54:18
问题 I have a sql file test.sql used to run some SQL (create object / update / delete / insert) that can look like this CREATE TABLE test_dbi1 ( test_dbi_intr_no NUMBER(15) , test_dbi_name VARCHAR2(100); UPDATE mytable SET col1=1; CREATE TABLE test_dbi2 ( test_dbi_intr_no NUMBER(15) , test_dbi_name VARCHAR2(100); Usually, i would just use SQLPLUS (from within Perl) to execute this test.sql using this command : @test.sql Is there a way to do the same thing, using DBI in Perl ? So far, i found DBI

should I commit in the following code?

最后都变了- 提交于 2019-12-14 04:16:45
问题 My code: 122 # 123 my $hfpDbh = undef; 124 unless ( 125 $hfpDbh = DBI->connect("dbi:Pg:host=....")#removed something 128 ) { 129 Log( ERROR, "" ); 130 Exit( 1 ) 131 } 132 $hfpDbh->{RaiseError} = 1; 133 $hfpDbh->{AutoCommit} = 0; 134 135 ( my $mydata, $msg ) = load_data( $hfpDbh, $DatFile ); 136 unless ( defined($mydata) ) 137 { 138 Log(INFO, "Calling exit...2"); 139 } 140 #$hfpDbh->disconnect(); 141 Exit( 0 ); 142 Log(INFO, "Calling exit...4"); 143 144 145 sub load_data 146 { 147 my ( $dbh,