Jump to content

Is it possible to save an array as SQLite table?


Recommended Posts

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to post
Share on other sites

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 by Zedna
Link to post
Share on other sites

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...

 

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...