I have very little experience with MySQL or any database other than the ones that came with my Perl package, so bare with me.
Using the example code from CPAN (see below) resulted in three files being created. test.pag, test.dir and test.lck. Then I created a new table and that created three more files prepended with "test1".
There must be some way to have the set of tabular data not each be their own separate files. If I have 100 tables, I can't handle 300 files in one directory just for the database to work.
From the code you can see I tried adding the extension ".db" as per the manual but that still resulted in the creation of three files per table.
When using my $dbh=DBI->connect('dbi:DBM:type=DB_File'); file instead, it still created three files but one of them didn't have an extension. So the question is, is there a way for this to create one or maybe two files total for the entire database or is this what to expect from DBD::DBM?
Second question is seems more of an SQL question but when you SELECT something from the table such as:
To store the results, you could use:SELECT phone FROM user WHERE user_name < 'Fred';
Right? Again, I have never really gotten into MySQL but this little DBI looks like it could come in handy so I don't have to continue split()ing all my values from my hashes.my $var = SELECT phone FROM user WHERE user_name < 'Fred';
Thanks for your help.
use DBI; my $dbh = DBI->connect('dbi:DBM:ext=.db'); $dbh->{RaiseError} = 1; for my $sql( split /;\n+/," CREATE TABLE test ( user_name TEXT, phone TEXT ); INSERT INTO test VALUES ('Fred Bloggs','233-7777'); INSERT INTO test VALUES ('Sanjay Patel','777-3333'); INSERT INTO test VALUES ('Junk','xxx-xxxx'); DELETE FROM test WHERE user_name = 'Junk'; UPDATE test SET phone = '999-4444' WHERE user_name = 'Sanjay Pate +l'; SELECT * FROM test "){ my $sth = $dbh->prepare($sql); $sth->execute; $sth->dump_results if $sth->{NUM_OF_FIELDS}; } $dbh->disconnect;
In reply to DBD::DBM file creation by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |