DatabaseUpdate() very slow on SQLITE

Just starting out? Need help? Post your questions and find answers here.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

DatabaseUpdate() very slow on SQLITE

Post 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
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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
Fred
Administrator
Administrator
Posts: 18237
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Sure you have to use transactions when doing a lot of update, it's standard SQL, not a bug.
dige
Addict
Addict
Posts: 1407
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Yes, thats true. Updates and also Inserts should wraped into Transactions.
Post Reply