dbi

Which Perl database interface should I use?

Is CPAN DBI the best database interface to use in Perl for general database use? Are there some better options? ...

Why would the rollback method not be available for a DBI handle?

For some reason I am having troubles with a DBI handle. Basically what happened was that I made a special connect function in a perl module and switched from doing: do 'foo.pl' to use Foo; and then I do $dbh = Foo->connect; And now for some reason I keep getting the error: Can't locate object method "rollback" via package "...

DBI's column_info vs. pgAdminIII on quoted identifiers

I have a table in my pgsql database with columns named "type", "desc", and "start". When I call $dbh->column_info, only "desc" comes back quoted, whereas in pgAdmin3 all three of them are quoted. Is one of them wrong? ...

How can I translate date values from Oracle to Excel using Perl's DBI?

Hi All, I am having trouble with a very simple Perl process. I am basically querying an Oracle database and I want to load it into Excel. I have been able to use DBIx::Dump and it works. However, I need to be able to use a variety of Excel formatting tools. And I think Spreadsheet::WriteExcel is the best module that outputs to Excel ...

How can I check if a database query will return results?

Our website uses Perl to provide a simple mechanism for our HR people to post vacancies to our website. It was developed by a third party, but they have been long since kicked into touch, and sadly we do not have any Perl skills in-house. This is what happens when Marketing people circumvent their in-house IT team! I need to make a simp...

How can I get the database name from a Perl MySQL DBI handle?

I've connected to a MySQL database using Perl DBI. I would like to find out which database I'm connected to. I don't think I can use: $dbh->{Name} because I call USE new_database and $dbh->{Name} only reports the database that I initially connected to. Is there any trick or do I need to keep track of the database name? ...

Does Parrot have a database interface or API?

A quick search gave me this announcement of Parrot DBDI from January 2004 and a dbdi-dev mailing list which appears to be long dead. Is Parrot DBDI still being developed? Is anyone working on a different database API or interface for Parrot? ...

How do I reference a scalar in a hash reference in Perl?

Simple question: How do I do this on one line: my $foo = $bar->{baz}; fizz(\$foo); I've tried \$bar->{baz}, \${$bar->{baz}}, and numerous others. Is this even possible? -fREW Update: Ok, the hashref is coming from DBI and I am passing the scalar ref into template toolkit. I guess now that I look more closely the issue is somethin...

How can I use DBD::Proxy with DBIx::Class?

I need to get a database connection through a firewall, and also limit what queries can be run. DBD::Proxy seems to be the perfect solution for this. However, I'm currently using DBIx::Class, and can't figure out how to hook them together. In particular, DBD::Proxy doesn't take SQL; it takes particular named queries. But DBIx::Class doe...

Is there a DBI proxy that handles SQL restrictions and transactions?

I am looking for a DBI (or similar) proxy that supports both SQL restrictions and transactions. The two I know about are: DBD::Proxy DBD::Gofer DBD::Proxy The problem I have found with DBD::Proxy is that its server, DBI::ProxyServer, doesn't just restrict queries coming in over the network (which I want), but it also restricts queri...

Is there a Perl DBI driver for SQL Server Compact 3.5?

Maybe I'm not looking in the right places but I'd like to use SQL Server Compact 3.5 as a back-end for an existing Perl app that uses DBI (on Windows). I'm looking specifically at SQL Server Compact 3.5 because I'd like to use the existing support for it in MS Sync Framework to get started instead of the SQLite db I'm currently using. ...

Why can't I connect to postgres from Perl?

I believe I have set up Pg properly, but my script doesn't seem to be connecting to the database. I am testing with: $database="networkem"; $user="postgres"; $password=""; $host="localhost"; $dbh = DBI->connect("DBI:Pg:dbname=$dbname;host=$host", $user, $password); My pg_hba reads: host all postgres 127.0.0.1 255.255.25...

How do I solve this issue with gethostbyname_r and DBI or DBD::MySQL on FreeBSD?

I have some old perl code which recently stopped working on a FreeBSD box. The code which fails looks (in simplest form) like this: #!/usr/local/bin/perl -w use strict; use DBI; my $datasource = "DBI:mysql:dbname:hostname.domain.com"; my $user = "username"; my $pass = "password"; DBI->connect($datasource, $user, $pass); This fails...

How can I handle non-ASCII characters when retrieving data from SQL Server using Perl?

I have a Perl script running on UNIX that uses DBI to connect to and retrieve data from a SQL Server database. The script looks like the following: $dbh = DBI->connect("dbi:Sybase:server=$connect;charset=UTF-8", $login, $password) or die("Couldn't connect to $connect as $login/$password: $DBI::errstr"); $sql = "use mydb"; $sth = $dbh-...

Where is detailed documentation on Class::DBI's sth_to_objects() method?

How do I find detailed documentation on the behavior of the sth_to_objects() method in the Class::DBI module? ...

How can I select rows that are null using bound queries in Perl's DBI?

I want to be able to pass something into an SQL query to determine if I want to select only the ones where a certain column is null. If I was just building a query string instead of using bound variables, I'd do something like if ($search_undeleted_only) { $sqlString .= " AND deleted_on IS NULL"; } but I want to use bound que...

Using Ruby Gem DBI

Hi, I want to access MySQL through ruby on a shared linux server. I figure I need to use the DBI module, but I can't seem to access it. I installed it as follows: gem install -r dbi It couldn't install it in the normal location, since I'm on a shared server and don't have permission: WARNING: Installing to ~/.gem since /usr/lib/rub...

Weird ruby segmentation fault with DBI and MySQL

[Edited to use much simpler code which shows the problem] The following code gives a segmentation fault on the last line require 'rubygems' gem 'mysql' gem 'dbi' require 'dbi' require 'mysql' dsn = "DBI:Mysql:DATABASE:www.HOST.net" # redacted dbh = DBI.connect(dsn, "USERNAME", "PASSWORD") # redacted sth = dbh.execute("select * from ...

How do I know how many rows a Perl DBI query returns?

I'm trying to basically do a search through the database with Perl to tell if there is an item with a certain ID,. This search can return no rows, but it can also return one. I have the following code: my $th = $dbh->prepare(qq{SELECT bi_exim_id FROM bounce_info WHERE bi_exim_id = '$exid'}); $th->execute(); if ($th->fetch()->[0] != $ex...

Is there any way to access that *.DB file using Sybase toolkit or Perl DBI, etc?

A medical office that I do work for uses MIS that does not have ODBC. There is an export function, however, and it seems to dump it into a "export.DB" file. In Windows, that is traditionally a Paradox database; however, in snooping around the directory architecture, it looks like there's a portable Sybase server. Is there any way to a...