Search code examples
sqliteshelllazarus

Accesing to sqlite shell from lazarus to run a sql script


I have a program in lazarus that read and process data from mysql5 database server then with this data creates a set of tables in sqlite to use it in a android app, in this set of tables there is one that the amount of records is around 12000, when I try to create this tables by using the Sqlite3 dataaccess object in lazarus like TSqlScript to do this creation script take a long time about 8-15 minutes, but executin this script with sqlite shell comand line take only fews seconds, how I Ejecute this script using the shell sqlite3 from lazarus.


Solution

  • When you do not use explicit transactions, SQLite will automatically wrap each single SQL statement into a transaction, which results in horrible overhead if you are using many statements.

    Explicitly use a single transaction around the entire script.