Deletion/record visibility error in PG with Python...
Durumdara
durumdara at gmail.com
Thu May 28 12:29:31 EDT 2009
Hi!
PGSQL makes me crazy...
I port my apps to PGSQL, and I near to finish - but I got this problem...
Params: PGSQL 8.3, Windows, Pylons, PGDB, DBUTILS...
I opened the connection with DBUTILS. I have one thread (the test thread),
possible it have more in the background, I don't know...
See this pseudocode:
start trs ("rollback; begin;")
delete old recs
insert new recs
commit
I delete all of old records with:
"delete from levelfo where level = :level"
This I do in one transaction that protect the next sequences to.
Later I want to insert the records, BUT:
def GetCodes(reks):
l = []
for rek in reks:
l.append(str(rek['KOD']))
return str(l)
def LogInsertedReks(Index):
csql = "select * from levelfo where level=%d" %
self.LevelRek['KOD']
self.Cur.execute(csql)
reks = dwdb.FetchAll(self.Cur)
self.log.info(Index + ' #### INSERTED REKS ####')
self.log.info('%s' % GetCodes(reks))
for levelforek in self.LevelFoReks:
LogInsertedReks('Start1')
LogInsertedReks('Start2')
LogInsertedReks('Start3')
LogInsertedReks('Start4')
LogInsertedReks('Start5')
LogInsertedReks('Start6')
kod = levelforek['KOD']
self.log.info('#### INSERT ####')
self.log.info('%s' % levelforek['KOD'])
LogInsertedReks('Start7')
LogInsertedReks('Start8')
LogInsertedReks('Start9')
See this log:
18:07:02,276 INFO [xxx] Start1 #### INSERTED REKS ####
18:07:02,276 INFO [xxx] []
18:07:02,292 INFO [xxx] Start2 #### INSERTED REKS ####
18:07:02,292 INFO [xxx] []
18:07:02,292 INFO [xxx] Start3 #### INSERTED REKS ####
18:07:02,292 INFO [xxx] []
18:07:02,306 INFO [xxx] Start4 #### INSERTED REKS ####
18:07:02,306 INFO [xxx] []
18:07:02,306 INFO [xxx] Start5 #### INSERTED REKS ####
18:07:02,306 INFO [xxx] []
18:07:02,306 INFO [xxx] Start6 #### INSERTED REKS ####
18:07:02,306 INFO [xxx] []
18:07:02,306 INFO [xxx] #### INSERT ####
18:07:02,306 INFO [xxx] 11551
18:07:02,306 INFO [xxx] Start7 #### INSERTED REKS ####
18:07:02,306 INFO [xxx] []
18:07:02,619 INFO [xxx] Start8 #### INSERTED REKS ####
18:07:02,619 INFO [xxx] ['11555', '11556', '11557', '11558']
18:07:02,634 INFO [xxx] Start9 #### INSERTED REKS ####
18:07:02,634 INFO [xxx] ['11555', '11556', '11557', '11558']
18:07:02,697 INFO [xxx] After UID #### INSERTED REKS ####
18:07:02,697 INFO [xxx] ['11555', '11556', '11557', '11558']
As you see, I don't do anything (like db operations), and deleted records
are appearing...
Hmmmm... possible is it a cursor changing?
When I change my logger to see the object ids, I can see the cursor changing
(in the background):
18:21:29,134 INFO [xxx] Start7 #### INSERTED REKS ####
18:21:29,134 INFO [xxx] []
18:21:29,134 INFO [xxx] Start7 #### CURSOR INFO ####
18:21:29,134 INFO [xxx] [<DBUtils.SteadyDB.SteadyDBCursor instance at
0x01955710>]
18:21:29,134 INFO [xxx] [<DBUtils.SteadyDB.SteadyDBConnection instance at
0x019555A8>]
********** 18:21:29,134 INFO [xxx] [<pgdb.pgdbCursor instance at
0x019556E8>]
18:21:29,431 INFO [xxx] Start8 #### INSERTED REKS ####
18:21:29,431 INFO [xxx] ['11555', '11556', '11557', '11558']
18:21:29,431 INFO [xxx] Start8 #### CURSOR INFO ####
18:21:29,431 INFO [xxx] [<DBUtils.SteadyDB.SteadyDBCursor instance at
0x01955710>]
18:21:29,431 INFO [xxx] [<DBUtils.SteadyDB.SteadyDBConnection instance at
0x019555A8>]
********** 18:21:29,431 INFO [xxx] [<pgdb.pgdbCursor instance at
0x0195AE18>]
What happened? How I can avoid the cursor changing? How to fix it in my
transaction?
I never ask for new cursor, I used same variable in all of my context
(self.Cur)... :-(
So what is the solution? Drop DBUtils? Or what?
Thanks for your help:
dd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090528/f4065a6b/attachment.html>
More information about the Python-list
mailing list