Re: sqlite3 db update extremely slow
- From: Steve Holden <steve@xxxxxxxxxxxxx>
- Date: Mon, 16 Jul 2007 21:32:24 -0400
coldpizza wrote:
Thanks a lot, Roel, adding a single commit() at the end did solve theIt'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.
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?
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 addedGenerally speaking each database instance will have an associated encoding. Trying to establish some other encoding would then be pissing into the wind.
records?
And how do set the encoding for the retrieved records? Is it always
utf-8 by default?
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 -------------
.
- Follow-Ups:
- Re: sqlite3 db update extremely slow
- From: Ben Finney
- Re: sqlite3 db update extremely slow
- References:
- sqlite3 db update extremely slow
- From: coldpizza
- Re: sqlite3 db update extremely slow
- From: Roel Schroeven
- Re: sqlite3 db update extremely slow
- From: coldpizza
- sqlite3 db update extremely slow
- Prev by Date: Re: Fetching a clean copy of a changing web page
- Next by Date: ANN: Tftpy 0.4.3
- Previous by thread: Re: sqlite3 db update extremely slow
- Next by thread: Re: sqlite3 db update extremely slow
- Index(es):
Relevant Pages
|