Page 1 of 1

DatabaseUpdate() very slow on SQLITE

Posted: Sun Jun 15, 2008 3:30 pm
by Num3
I had to change all the lines of this code to DatabaseQUERY(), or i would have to wait about 5 minutes for it to execute!

Code: Select all

If OpenDatabase(#DB_MISC, "dados\misc.db3", "", "")
  
  If DatabaseQuery(#DB_MISC, "SELECT * FROM div;")
    IMPREVISTO = ValF(GetGadgetText(#Gadget_opcoes_imprevisto))
    DatabaseUpdate(#DB_MISC, "UPDATE div SET value='" + StrF(IMPREVISTO, 2) + "' where id='imprevisto';")
    
    MT = ValF(GetGadgetText(#Gadget_opcoes_mtpiso))
    DatabaseQuery(#DB_MISC, "UPDATE div SET value='" + StrF(MT, 2) + "' where id='mt';")
    
    AUMENTO = ValF(GetGadgetText(#Gadget_opcoes_aum_gen))
    DatabaseUpdate(#DB_MISC, "UPDATE div SET value='" + StrF(AUMENTO, 2) + "' where id='aumento';")
  EndIf
  
  C1_REP = ValF(GetGadgetItemText(#Gadget_opcoes_C1, 0, 1))
  DatabaseUpdate(#DB_MISC, "UPDATE c1 SET value='" + StrF(c1_REP, 2) + "' where id='REP';")
  
  C1_MOD = ValF(GetGadgetItemText(#Gadget_opcoes_C1, 1, 1))
  DatabaseUpdate(#DB_MISC, "UPDATE c1 SET value='" + StrF(c1_MOD, 2) + "' where id='MOD';")
  
  CloseDatabase(#DB_MISC)
EndIf

Posted: Sun Jun 15, 2008 7:16 pm
by Mistrel
I'm not familiar with the new sqlite library but this is how I would do it before:

http://www.purebasic.fr/english/viewtopic.php?t=29413

Posted: Sun Jun 15, 2008 8:14 pm
by Fred
Sure you have to use transactions when doing a lot of update, it's standard SQL, not a bug.

Posted: Mon Jun 16, 2008 8:48 am
by dige
Yes, thats true. Updates and also Inserts should wraped into Transactions.