[vox-tech] sqlite + perl - wierd unrecognized token error
Peter Jay Salzman
p at dirac.org
Thu Dec 23 11:55:40 PST 2004
On Thu 23 Dec 04, 11:15 AM, Shwaine <shwaine at shwaine.com> said:
> On Thu, 23 Dec 2004, Peter Jay Salzman wrote:
> <snip>
> > DBD::SQLite::db do failed: unrecognized token: ":" at Create_Tables.pm
> > line
> > 52, <> line 6.
> >
> <snip>
> >Excerpt from Create_Tables.pm:
> >
> <snip>
> > my $dbh = DBI->connect("dbi:SQLite:$table_name");
> >
> <snip>
> >Statement handle DBI::st=HASH(0x840773c) DESTROY ignored - never set up
> > ERROR: 1 'unrecognized token: ":"' (err#0)
>
> In my MySQL connections, I have database=$table_name, not just
> $table_name. That is a driver specific syntax though, so you may want to
> check the documentation for your specific driver to see if that is the
> syntax it expects.
The alternate syntax (database=$tablename) didn't generate any errors, so at
least the dbi driver for sqlite understood it. Unfortunately, it still
gives the same unrecognized token error.
> Another thing I did when debugging a program was to put
> the SQL command in a string, print the string, then pass the string to do.
> Then I could see exactly what was passed to do.
DOH!!! Now why didn't *I* think of that?!?
Grade Utility
+-=-=-=-=-=-=-=-=-=-+
1. Create a new class
2. Add a student
3. Modify a record
4. Print_Record()
5. Dump_All_Records
q. Quit
+-=-=-=-=-=-=-=-=-=-+
Choice: 1
Enter semester: qwer
Enter course: asdf
Enter Course Desc: zxc
Enter college: ve
Enter reference: sadf
INSERT INTO course VALUES (
DBI::db=HASH(0x83f16fc)->quote ( qwer ),
DBI::db=HASH(0x83f16fc)->quote ( asdf ),
DBI::db=HASH(0x83f16fc)->quote ( zxc ),
DBI::db=HASH(0x83f16fc)->quote ( ve ),
DBI::db=HASH(0x83f16fc)->quote ( sadf )
DBD::SQLite::db do failed: unrecognized token: ":" at Create_Tables.pm line 74, <> line 6.
Uncaught exception from user code:
DBD::SQLite::db do failed: unrecognized token: ":" at Create_Tables.pm line 74, <> line 6.
Create_Tables::Create_Database('HASH(0x835dcd8)') called at ./driver.pl line 66
main::Create_Course() called at ./driver.pl line 30
main::main_menu() called at ./driver.pl line 73
)
Looks like
$dbh->quote( blah )
isn't executing the quote method. I think the problem is that I'm calling
the method inside a double quote:
$dbh->do("
INSERT INTO course VALUES (
$dbh->quote ( $course->{semester} ),
$dbh->quote ( $course->{course} ),
$dbh->quote ( $course->{course_desc} ),
$dbh->quote ( $course->{college} ),
$dbh->quote ( $course->{reference} )
)
");
so I think I want this, instead (or something equivalent):
$dbh->do("
INSERT INTO course VALUES ( " .
$dbh->quote ( $course->{semester} ) . ", " .
$dbh->quote ( $course->{course} ) . ", " .
$dbh->quote ( $course->{course_desc} ) . ", " .
$dbh->quote ( $course->{college} ) . ", " .
$dbh->quote ( $course->{reference} )
)
");
Thanks!
Pete
--
The mathematics of physics has become ever more abstract, rather than more
complicated. The mind of God appears to be abstract but not complicated.
He also appears to like group theory. -- Tony Zee's "Fearful Symmetry"
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
More information about the vox-tech
mailing list