sqlite - merge two databases
BlitzMax Forums/Brucey's Modules/sqlite - merge two databases
| ||
| If have two databases that I want to combine. Let's call 'em dbFrom and dbTo. example: The problem is that this is not working. Nothing happens in dbTo. Im a newbie to sql but I think the query is correct, isn't it? |
| ||
| Hello, something like this works: Strict
Import bah.dbsqlite
Local db:TDBConnection = LoadDatabase("SQLITE", "source.db")
If db.isOpen()
Local sql:String
sql = "ATTACH 'target.db' AS target"
db.executeQuery(sql)
If db.hasError() Then DebugLog db.error().toString()
sql = "INSERT Or REPLACE INTO target.table_1 SELECT * FROM table_1"
db.executeQuery(sql)
If db.hasError() Then DebugLog db.error().toString()
DebugLog "done"
db.close()
EndIf...if you want to copy a table between databases (both tables with similar structures) -Henri |
| ||
| Ok, that works. But isn't it possbile to have the target db open and attach the source? |
| ||
| I don't see why not. If the table names are not unique you have to specify which database the table comes from. -Henri |