Re: sqlite3 db update extremely slow



coldpizza wrote:
Thanks a lot, Roel, adding a single commit() at the end did solve the
speed problem.

Another question is do I have to explicitly close the DB connection,
or is it automatically garbage collected? Is it Ok to no have any
cleanup code?

It's generally OK, but you can register a function with atexit() if you are paranoid about cleanup. Here's a sample with an ugly global variable.

from atexit import register

def close():
global conn
if conn:
conn.close()
print "Database closed"
conn = None

#
# We try to ensure the database is always closed by registering
# the nodule's close() function to be called on program exit
#
register(close)

import psycopg2 as db
conn = db.connect(database="billing", user="steve", password="tadaa!")
curs = conn.cursor()

print "Database opened"

Another question would be how to define the encoding for newly added
records?
And how do set the encoding for the retrieved records? Is it always
utf-8 by default?

Generally speaking each database instance will have an associated encoding. Trying to establish some other encoding would then be pissing into the wind.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

.



Relevant Pages

  • Accepting Bids on Web application programming Development contract
    ... Real Estate Multipliable Listing Service Web application. ... customer as pkzip or tar ... Register function common specs ... time you search the real estate record database for the ...
    (freebsd-questions)
  • Re: ODBC Connection to SQL Server Compact
    ... Sylvain Lafontaine, ing. ... "The database file has been created by an earlier ... The conn object opened "nicely". ... Dim Conn As ADODB.Connection ...
    (microsoft.public.access.modulesdaovba)
  • Re: Proper Database Connection Cleanup
    ... Public Sub ConnectToDB2(byref XCmd, byref YRS, byRef Conn) ... Public Sub CloseDBCon ... I am new to using their database and I do connect two or three ...
    (microsoft.public.scripting.vbscript)
  • Re: Server-to-Server Remoting
    ... I can only use one database connection per ... You can't send an object from server b that you got at ... > server a and send it to client c. ... >>My problem is that I can't figure out how to register and instantiate ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Buy a mobile phone.. register it with the government
    ... A compulsory national register for the owners of all 72m mobile phones ... in Britain would be part of a much bigger database to combat terrorism ... How is having to show ID when you purchase a new phone a "massive ...
    (uk.media.tv.misc)