in reply to Re: my first database
in thread my first database
You guys should really investigate "Statement Handle Attributes" in the DBI pod. Even those depend on the underlying driver, but since they've been a part of DBI longer, they are more portable.
I recently started using DBD-SQLite, and after converting my mysql-specific sql into equivalent ANSI92 DBD-SQLite compliant using code from Re: MySQL 2 SQLite, I came up with the following to dump some metadata about my database ;)
update: ++ That is all true, but if you're looking for a list of tables, soon you'll be looking to describe those tables, and ... you get the point, yes? yes ;)use DBI; use Data::Dumper; my $dbh = DBI->connect("dbi:SQLite:pod.wiki.sqlite.db") or die $DBD::e +rr; warn "database name is ", $dbh->{Name}; my $sth = $dbh->prepare("SELECT * FROM content limit 0"); warn $sth->execute; for my $attr( qw[ NUM_OF_PARAMS NUM_OF_FIELDS NAME NAME_hash TYPE PRECISION SCALE NULLABLE]){ eval { warn $attr, ' ', Dumper($sth->{$attr}); }; warn $attr,' is unavailable (', 1||$@, ')' if $@; } __END__ database name is pod.wiki.sqlite.db at dbi.table.info.pl line 5. 3 at dbi.table.info.pl line 7. NUM_OF_PARAMS $VAR1 = 0; NUM_OF_FIELDS $VAR1 = 5; NAME $VAR1 = [ 'name', 'version', 'text', 'modified', 'comment' ]; NAME_hash $VAR1 = { 'text' => 2, 'modified' => 3, 'comment' => 4, 'version' => 1, 'name' => 0 }; TYPE is unavailable (1) at dbi.table.info.pl line 11. PRECISION is unavailable (1) at dbi.table.info.pl line 11. SCALE is unavailable (1) at dbi.table.info.pl line 11. NULLABLE is unavailable (1) at dbi.table.info.pl line 11.
|
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests. ** The Third rule of perl club is a statement of fact: pod is sexy. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: my first database
by jasonk (Parson) on Feb 13, 2003 at 16:38 UTC |