Hello! 1. Use tcl backup API
The "backup" method The "backup" method makes a backup copy of a live database. The command syntax is like this: dbcmd backup ?source-database? backup-filename The optional source-database argument tells which database in the current connection should be backed up. The default value is main (or, in other words, the primary database file). To back up TEMP tables use temp. To backup an auxilary database added to the connection using the ATTACH command, use the name of that database as it was assigned in the ATTACH command. The backup-filename is the name of a file into which the backup is written. Backup-filename does not have to exist ahead of time, but if it does, it must be a well-formed SQLite database. The "restore" method The "restore" method copies the content a separate database file into the current database connection, overwriting any preexisting content. The command syntax is like this: dbcmd restore ?target-database? source-filename The optional target-database argument tells which database in the current connection should be overwritten with new content. The default value is main (or, in other words, the primary database file). To repopulate the TEMP tables use temp. To overwrite an auxilary database added to the connection using the ATTACH command, use the name of that database as it was assigned in the ATTACH command. The source-filename is the name of a existing well-formed SQLite database file from which the content is extracted. 2. Use sql commands to copy database structure from sqlite_master table and copy data 2006-02-20: A simple TCL-Implementation for loading a DB into memory: proc loadDB {dbhandle filename} { if {$filename != ""} { #attach persistent DB to target DB $dbhandle eval "ATTACH DATABASE '$filename' AS loadfrom" #copy each table to the target DB foreach {tablename} [$dbhandle eval "SELECT name FROM loadfrom.sqlite_master WHERE type = 'table'"] { $dbhandle eval "CREATE TABLE '$tablename' AS SELECT * FROM loadfrom.'$tablename'" } #create indizes in loaded table foreach {sql_exp} [$dbhandle eval "SELECT sql FROM loadfrom.sqlite_master WHERE type = 'index'"] { $dbhandle eval $sql_exp } #detach the source DB $dbhandle eval {DETACH loadfrom} } } Best regards, Alexey Pechnikov. http://pechnikov.tel/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users