DBI under the MAC

[email protected] (Sean Murphy) Fri, 9 Dec 2011 22:42:49 +1100
Newsgroups perl.macperl.anyperl
Message-ID <[email protected]>
Hi All.

I am having some strange behaviours. I have created a simple script to =
insert data into a SQLite database. When I use the prepare  are=20
statement. The DBI driver complains that there is no such table.=20

The code looks like thus:

#!/usr/bin/perl

# Combining credit and savings sheets
# to find expenses and income.


use strict;
                                                          use DBI;
                                                         =20
my $db_driver =3D "SQLite";
my $db_file =3D "budget.db";
my $dns =3D "DBI:$db_driver:database=3D$db_file";

my $dbh =3D DBI->connect ($dns, '', '',
            { RaiseError =3D> 1, AutoCommit =3D> 0});

my $sth1 =3D $dbh->prepare("insert into cat (name) values (?);")
         or die("Cannot prepare table: " . DBI::errstr() );

my $sth2 =3D $dbh->prepare("insert into trans (accounts, =
transaction_date, description, amount, amount_type, transaction_type, =
serial, category_id) values (?, ?, ?, ?, ?, ?, ?, ?);")
	          or die("Cannot prepare: " . DBI::errstr() );


When the above is executed in the full script. We get the following =
error:

DBD::SQLite::db prepare failed: table trans has no column named accounts =
at ./insert_budget.pl line 60.
Cannot prepare: table trans has no column named accounts at =
./insert_budget.pl line 60.

The Schema for the table shows trans being present. As follows:

sqlite> .schema trans
CREATE TABLE trans (transaction_id int primary key, account int, =
transaction_date date, description varchar(80), amount decimal (11,2), =
amount_type varchar(3) not null, transaction_type varchar(40), serial =
varchar(40), category_id int);
sqlite>=20

Any ideas what might be going on here? The drivers are being found. I =
have tested this by using the perl -d option with the script.

Sean=20