in reply to Can SQL be used without a database?


If you are into small scale,rapid application development then SQLite is definately the thing for you.
So what all do you need to get started with an SQLite driven application?
1. Install the DBI (1.39 was the latest last i checked)
2. Install DBD::SQLite (0.29)
3. Install the dbish (11.93)
As jeffa has shown in his examples above ,you can use a script to create a table .
The other way to do this is too run /opt/perl5/bin/dbish
This gives you a shell interface to your database.
Make a file to hold your records e.g touch /record.db
After running the dbish choose the option to connect to the sqlite database (option 3).
Then provide the dsn e.g. dbi:SQLite:/record.db
Once you are connected to the db you can run your create,insert,delete,update commands.
However,if you want to shift records from a flat file into a database it is advisable to write a script . An example of this is below:
Flat file example
10.50.0.0 255.255.0.0 164.130.4.0 255.255.252.0 164.130.8.0 255.255.248.0 164.130.16.0 255.255.240.0 164.130.32.0 255.255.248.0 164.130.40.0 255.255.252.0

And the script to read it and insert records into a table
use DBI; my $dir='/ipmap'; my $id=0; opendir(DIR,$dir); my @files = grep { $_ ne "." and $_ ne ".." } readdir DIR; closedir(DIR); my %attrib = ( PrintError => 0, RaiseError => 1 ); my $dbh = DBI->connect('dbi:SQLite:ipadd.db',"","",\%attrib); my $query = $dbh->prepare("insert into siteip (tla,ip,range) values (? +,?,?)"); print "@files\n"; foreach my $file (@files) { chomp($file); my @ins=''; my($tla,undef)=split(/\./,$file); print "Processing for $tla\n"; open(FI,"$dir\/$file")|| die $!; while(<FI>) { $id=+1; next if m/^\s*$/ or m/^\s*#/; my $line=$_; @ins = split(/\s+/,$line); # print "Inserting $tla $ins[0] $ins[1]"; $query->execute("$tla","$ins[0]","$ins[1]"); } } $dbh->disconnect;

Hope this helps in your first attemp at using SLite.
cheers
chimni