Re: macperl-anyperl Digest 9 Dec 2011 11:43:02 -0000 Issue 112

[email protected] (Joel Rees) Fri, 9 Dec 2011 21:26:25 +0900
Newsgroups perl.macosx,perl.macperl.anyperl
Message-ID <[email protected]>
>
> From: Sean Murphy <[email protected]>
> Date: =E5=B9=B3=E6=88=9023=E5=B9=B412=E6=9C=889=E6=97=A5 20:42:49:JST
> To: [email protected]
> Subject: DBI under the MAC
>
>
> Hi All.
>
> I am having some strange behaviours. I have created a simple script =20=

> to insert data into a SQLite database. When I use the prepare  are
> statement. The DBI driver complains that there is no such table.
>
> The code looks like thus:
>
> #!/usr/bin/perl
>
> # Combining credit and savings sheets
> # to find expenses and income.
>
>
> use strict;
>                                                           use DBI;
>
> 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, =20
> transaction_date, description, amount, amount_type, =20
> transaction_type, serial, category_id) values =20
> (?, ?, ?, ?, ?, ?, ?, ?);")
> 	          or die("Cannot prepare: " . DBI::errstr() );
>
>
> When the above is executed in the full script. We get the following =20=

> error:
>
> DBD::SQLite::db prepare failed: table trans has no column named =20
> accounts at ./insert_budget.pl line 60.
> Cannot prepare: table trans has no column named accounts at ./=20
> 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, =20
> transaction_date date, description varchar(80), amount decimal =20
> (11,2), amount_type varchar(3) not null, transaction_type varchar=20
> (40), serial varchar(40), category_id int);
> sqlite>
>
> Any ideas what might be going on here? The drivers are being found. =20=

> I have tested this by using the perl -d option with the script.
>
> Sean

 =46rom the content of your question, I'm guessing that you're working =20=

with Mac OS X and therefore non-MacPerl perl.

This list is for MacPerl, which is perl on the old pre-Mac OS X Mac =20
systems.

The list you probably want is at [email protected] .

I really shouldn't forward this to that list, but I will.

As far as your question is concerned, I'm not familiar with SQLite, =20
but it looks to me like your problem is not Mac OS X related. You =20
might want to check your table definition again.

Joel Rees
(waiting for a 3+GHz ARM processor to come out,
to test Tim's willingness to switch again.)