2009/4/29 Tom van Ees <tvan...@davincigroep.nl>:
> Hi,
>
> my java application uses a 80Mb reference database (read-only) that needs to 
> be consulted app. 4M times during a batch run. I would like to use the 
> in-memory capabilities of sqlite3 to improve the performance of my app.
>
> In order to do so, I setup a Connection to the -in-memory- sqlite database 
> and next I would like to load the file-version of the reference database as 
> efficiently as possible into the in-memory version. What would be the 
> practical approach? The .restore/.backup commands do not seem to agree with 
> the jdbc-driver.

Perhaps jdbc-driver needs update to implement  .restore/.backup?

Anyway, the following tcl script should give an idea of what would work...

# create memory db connection
#
sqlite3 db :memory:

# attach to the source file
#
db eval "attach 'mySource.db' as srcDb;"

# copy schema tables
#
db eval "
        select sql from srcDb.sqlite_master
        where   type = 'table';
" {
        db eval "$sql"
  }

# copy the data for all tables
#
db eval "
        select name from srcDb.sqlite_master
        where type = 'table';
" {
        db eval "insert into $name select * from srcDb.$name;"
  }

# copy schema views, indexes and triggers (+any other non-tables that
I have not thought of)
#
db eval "
        select sql from srcDb.sqlite_master
        where   type <> 'table';
" {
        db eval "$sql"
  }

#  tidy up
#
db eval "detach srcDb;"

>
> regards
>
> Tom
>

Rgds,
Simon
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to