dbi

Why is there a “0 CLEARED by call to connect method” warning in DBI_TRACE?

廉价感情. 提交于 2020-01-15 05:40:31
问题 I'm wondering why a warn appears when using DBI_TRACE=1 upon connecting to any DB. Bonus points to a way to write clean code that doesn't exhibit it. I'm speaking about the !! warn: 0 CLEARED by call to connect method that seems harmless, since the code does work as intended. Note that it doesn't appear without setting the DBI trace mode. Sample Perl code (using SQLite): use warnings; use DBI; DBI->connect("dbi:SQLite:dbname=test.sqlite","","") or die $DBI::errstr; Sample output : DBI 1.612

Setting AutoCommit and begin_work/rollback are the same?

此生再无相见时 提交于 2020-01-15 05:36:45
问题 This question is about Perl DBI (I use it with MySQL). I want the following code: { local $dbh->{AutoCommit} = 0; ... if(...) { $dbh->rollback; } ... } Will it work as expected? (I mean no superfluous commit after rollback) Is $dbh->{AutoCommit} compatible with $dbh->begin_work and $dbh->rollback? 回答1: Yes, you can do that but why would you want to. Why not just call begin_work and then commit or rollback. They work fine even if AutoCommit is on. use strict; use warnings; use DBI; use Data:

DBI: raiseerror in eval

一曲冷凌霜 提交于 2020-01-13 06:24:09
问题 This question refers to this comment from Ikegami: [...] But if you're going to put an eval around every statement, just use RaiseError => 0. [...] in this thread. What do I gain, if I set RaiseError to 0 in such situations? #!/usr/bin/env perl use warnings; use 5.10.1; use DBI; my $db = 'my_test_sqlite_db.sqlite'; open my $fh, '>', $db or die $!; close $fh or die $!; my ( $dbh, $sth ); eval { $dbh = DBI->connect( "DBI:SQLite:dbname=$db", "", "", {} ); }; if ( $@ ) { print $@ }; my $table =

Where to put ruby .gem files so that Shoes.setup can find them?

六眼飞鱼酱① 提交于 2020-01-02 05:58:08
问题 A lot of questions have been asked about gem support in Shoes, but none have answered where to put them. I've got Shoes Raisins 1134 on Windows XP, and I've downloaded dbi-0.4.1.gem and am trying to get the following to work: Shoes.setup do gem 'dbi' end require 'dbi' Shoes.app ... end When I run this, I get the dialog that says Installing dbi -- Looking for dbi which sits for hours not finding the gem file. I've tried putting it in all of the following places to no avail: The folder that

Where to put ruby .gem files so that Shoes.setup can find them?

穿精又带淫゛_ 提交于 2020-01-02 05:58:06
问题 A lot of questions have been asked about gem support in Shoes, but none have answered where to put them. I've got Shoes Raisins 1134 on Windows XP, and I've downloaded dbi-0.4.1.gem and am trying to get the following to work: Shoes.setup do gem 'dbi' end require 'dbi' Shoes.app ... end When I run this, I get the dialog that says Installing dbi -- Looking for dbi which sits for hours not finding the gem file. I've tried putting it in all of the following places to no avail: The folder that

How can I get column names and row data in order with DBI in Perl?

时光怂恿深爱的人放手 提交于 2020-01-01 08:18:12
问题 I'm using DBI to query a SQLite3 database. What I have works, but it doesn't return the columns in order. Example: Query: select col1, col2, col3, col4 from some_view; Output: col3, col2, col1, col4 3, 2, 1, 4 3, 2, 1, 4 3, 2, 1, 4 3, 2, 1, 4 ... (values and columns are just for illustration) I know this is happening because I'm using a hash , but how else do I get the column names back if I only use an array? All I want to do is get something like this for any arbitrary query: col1, col2,

error of importing DBI in Perl

橙三吉。 提交于 2019-12-31 05:30:05
问题 I am writing the code in Perl and try to save it in the extension .pm not .pl and I use use DBI; to import the DBI in order that I can execute the query. and the error is compilation failed in require . However, I did use in script.pl , it s okay.. it works.. Please help and thank you very much 回答1: You probably simply miss the "1;" at the end of the .pm file. Perl modules always have to return a "true" value. This is accomplished by simply putting "1;" at the end of the file. More

How do I connect to an MS Access database using Perl?

大兔子大兔子 提交于 2019-12-29 08:01:13
问题 I have a .accdb file on my local machine and I am trying to connect to it and read some data from 3 tables within the DB. How do I establish the connection using Perl? So far I have scraped together this much for MS Access, but I am getting errors saying that I am not using the correct driver. Any ideas? my $msaccess_dbh = DBI->connect( 'dbi:ODBC:driver=microsoft access driver (*.accdb);' . 'dbq=C:\path\to\database\databasefile.accdb' ); Thanks! EDIT: Just to clarify, I have no real

Perl modules: MySQL vs DBI

柔情痞子 提交于 2019-12-25 04:42:13
问题 A lot of our automated processes use perl and need to access our MySQL DBs. I hate to admit it, but up until recently we haven't really done much benchmarking with the majority of our processes. One of our devs setup a test to compare the performance of "use MySQL" vs "use DBI" with the following pseudocode: for ($i = 1; $i <= 1000; $i++) { pull and store all records in a 4,000 record table } Results: MySQL - 57s, 56s, 57s DBI - 43s, 42s, 43s For some reason I was surprised to see DBI

RaiseError (PERL, DBI) equivalent for unixODBC C API?

回眸只為那壹抹淺笑 提交于 2019-12-25 02:26:01
问题 I have a problem executing some stored procedures/functions in INFORMIX DB. I tried with different clients and they were all the same - no one detects errors on executing, instead of this - return empty responses. And this does not work for me. Finally, I found that PERL DBI has the option to set RaiseError , something like: { PrintError => 0, RaiseError => 1 } And this works perfect. But is there such equivalent (I couldn't find anything, unfortunately) for the unixODBC C API lib? In