Vitaliy4us Posted December 19, 2019 Posted December 19, 2019 Is there any way to save an array as a table in SQLite database? It takes a lot of time to use a loop for this aim.
jchd Posted December 19, 2019 Posted December 19, 2019 Post you code, or at least a runable snippet. There are multiple techniques to speed up things. Also, post the complete DDL (the schema) of the DB, or at least the DLL for the relevant table. There are many possibilities making a schema slow. Finally, post a sample of your input table and tell how large it is in practice. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Zedna Posted December 19, 2019 Posted December 19, 2019 (edited) As far as I know there are some import functions (.import or something like this) from TXT file, so you may try to save your array to TXT and import it to the SQLite database. But it's question if this would be more (speed) effective than classic loop of "insert into ..." commands. EDIT: here is documented .import functionality in sqlite3.exe shell: https://www.sqlite.org/cli.html .import FILE TABLE Import data from FILE into TABLE Edited December 19, 2019 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Gianni Posted December 20, 2019 Posted December 20, 2019 The script pointed here above, seems to use a simple loop along all rows of the array inserting each record for each row one record at a time. To improve performances of records insertion into a sqlite table, you could use instead the so called "chain insertion" see here: https://www.autoitscript.com/forum/topic/166536-manage-arrays-by-means-of-sql/?do=findComment&comment=1216694 I've used this way of insertion in this script (https://www.autoitscript.com/forum/topic/166536-manage-arrays-by-means-of-sql/?do=findComment&comment=1230981) that manages arrays by means of sqlite. Even if unluckily you can't use it as is for your goal, cause the created table is just a temporary table in memory, you could modify it a bit so to manage a table belonging to DB on the disk. Anyway I hope it can be usefull for you as an example... Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
jchd Posted December 20, 2019 Posted December 20, 2019 Yep, the multiple input SQL syntax INSERT into T values (...), (...), (...), ... (...) is far faster than a loop with single insert. There are also other tracks: a virtual table, a carray, the CLI (mentionned above), json1, ... Still insert performance highly depends on the full table schema and nature of the inserted data. Hard to advise without more specifics. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now