I'm trying to create a SQLite database...I get no errors with this code but when I go to the SQLite3 procedure and do .schema or .table, I get nothing....I would greatly appreciate a helping hand.
#! perl use strict; use warnings; use DBI; my $dbh; &do_connect(\$dbh); &create_tables($dbh); exit; sub do_connect { # my $dbh = shift or die "code_review:do_connect: must pass in +handle...$!\n"; my $driver = "SQLite"; my $database = "/home/user/bmcclintock/code_review.db"; my $username = undef; my $password = undef; my $dsn = "DBI:$driver:database=$database"; $dbh = DBI->connect( $dsn, $username, $password ); } sub create_tables { my $dbh = shift; # Delete the table if it already exists. eval { local $dbh->{PrintError} = 1; $dbh->do("DROP TABLE review") and print "review dropped\n"; $dbh->do("DROP TABLE depot") and print "depot dropped\n"; $dbh->do("DROP TABLE reviewer") and print "reviewer dropped\n"; die "error in dropping tables\n" if $@; }; my $table = "review"; $dbh->do("CREATE TABLE $table (key INTEGER PRIMARY KEY, submitter VARCHAR(50), director VARCHAR(50), change_num INTEGER, action VARCHAR(20), time DATE )") or die "code_review::create_table: + could not create <$table>...$!\n"; print "\n$table created\n"; $table = "depot"; $dbh->do("CREATE TABLE $table (change_num INTEGER PRIMARY KEY, depot VARCHAR(50) )") or die "code_review::create_table: + could not create <$table>...$!\n"; print "$table created\n"; $table = "reviewer"; $dbh->do("CREATE TABLE $table (change_num INTEGER PRIMARY KEY, reviewed_by VARCHAR(50) )") or die "code_review::create_table: + could not create <$table>...$!\n"; print "$table created\n"; $dbh->do("CREATE TRIGGER INS_TIMEENTER AFTER INSERT ON REVIEW BEGIN UPDATE REVIEW SET TIME = DATETIME('NOW','LOCALTIME') WHERE ROWID = NEW.ROWID; END"); print "\ntables created\n"; }

In reply to create SQLite database problems by fionbarr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.