[Lazarus] RE : SQLite performance problem. Simple query takes toolong.
Ludo Brands
ludo.brands at free.fr
Fri Jul 29 16:13:17 CEST 2011
> I have established that the problem is not in SQLite, but has
> to be in my code somewhere. I suspect it is related to the
> transaction/commit problem I posted a few days ago, and I
> plan to track that down today if I can. I need to finish this
> application by tomorrow.
>
I read your previous messages again. By the looks of it you're using a very
hybrid way of using SQLite3Connection trying to do things yourself that the
components are supposed to do (starting transactions for example).
Here is a basic example of inserting data with direct sql queries:
-drop a TSQLite3Connection, a TSQLTransaction and a TSQLQuery on a form, a
data module or create them in code.
-set TSQLite3Connection properties to connect to your database
-assign TSQLTransaction.Database to the TSQLite3Connection instance
-assign TSQLQuery.Database to the TSQLite3Connection instance and
TSQLQuery.Transaction to the SQLTransaction instance. Active:= False,
SQL.Text:=''.
Now to execute an insert query (assuming
TSQLite3Connection.Connected:=true):
SQLQuery.SQL.Text:=sql;
SQLQuery.ExecSQL;
SQLTransaction.CommitRetaining;
That's it. SQLTransaction.CommitRetaining; does the COMMIT and a BEGIN to
start a new transaction.
Just to be complete, I'm using lazarus 0.9.31 svn with fpc 2.5.1 svn.
Ludo
More information about the Lazarus
mailing list