Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks
This may be a silly question, but I haven't found a solution. I want to create a table in a Sqlite database with the column names passed to the statement as an array. The number of columns should correspond to the number of elements of the array and the column names to the values of each element. The following doesn't work.
my @columns = qw/author year day month/; my $dbh = DBI->connect( "dbi:SQLite:my.db" ) || die "Cannot connec +t: $DBI::errstr"; $dbh->do( "CREATE TABLE Data (@columns )" ); $dbh->disconnect;
Is it possibile to achive what I described?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Sqlite create table dynamically
by choroba (Cardinal) on May 05, 2017 at 15:18 UTC | |
by Anonymous Monk on May 05, 2017 at 16:07 UTC | |
|
Re: DBI Sqlite create table dynamically
by MidLifeXis (Monsignor) on May 05, 2017 at 17:20 UTC | |
by dsheroh (Monsignor) on May 06, 2017 at 09:06 UTC | |
by Anonymous Monk on May 05, 2017 at 21:23 UTC |