[DB-SIG] PoPy v2.0.1 user competency issues

Thierry MICHEL thierry@nekhem.com
Thu, 1 Mar 2001 11:42:04 +0000


Hi,

This problem is that postgresql exits the transaction when an error
occurs.
I prepare a patch to resolv this problem, I notice you and the DB-API
list when it's fixed.

Thanks.
Best regards   

On Wed, Feb 28, 2001 at 11:32:37AM -0800, Timothy Grant wrote:
> Hi all,
> 
> Two things:
> 
> First of all, I have a feeling my lack of knowledge about how a
> database interface is supposed to work is hindering my ability
> to understand why PoPy is misbehaving.
> 
> Here's what I am doing:
> 
> I get a large quantity of data from an external data source.
> 
> I parse the data, and then build two SQL queries from it: one
> that does an insert and one that does an update.
> 
> I then attempt to do an insert in a try/except block.
> 
> If the insert fails, I know that I have to do an update and I
> execute the update in the except block.
> 
> I started using this before I installed v2.0.1. I also turned
> autocommit on.
> 
> I get the feeling that while my code was running it was not
> working correctly at all.
> 
> I installed PoPy v2.0.1 and something happened to autocommit.
> So I commented out all the lines having to do with autocommit
> and proceeded on my merry way. Now, however, I get the
> following output from my both my test programme and the "real"
> programme. Could some one improve my understanding of how these
> things are supposed to work, and what silliness I have
> implemented?
> 
> Posted below is the output from my programme, and then below
> that the test script itself.
> 
> Thanks for any input you may have.
> 
> [homer rmls]$ ./test.py 
> Attempting Insert
> Attempting Update
> NOTICE:  current transaction is aborted, queries ignored until
> end of transaction block
> 
> from PoPy import *
> 
> #Database settings
> dbname     = 'foobar'
> dbusername = 'tjg'
> dbhost     = 'localhost'
> 
> TRUE=True=true=1
> 
> def main():
>     db = connect('dbname=%s user=%s host=%s' % (dbname,
> 	dbusername, dbhost))
> 
> 	sqlin = "insert into test values (11, 'Jennifer', '503-555-1212');"
>     sqlup = "update test set name = 'Jennifer' where id = 11;"
> 
>     try:
>         print 'Attempting Insert'
>         cr = db.cursor()
>         cr.execute(sqlin)       
>         cr.close()
>     except:
>         print 'Attempting Update' 
> 		cr = db.cursor()
> 	    cr.execute(sqlup)
>         cr.close() 
> 																			
>     db.commit() 
> 
> I have a feeling my vim newbieness may have messed up the
> indentation on the above, though I'm not sure.
> 
> 
> -- 
> Stand Fast,
>     tjg.
> 
> Timothy Grant                         tjg@exceptionalminds.com
> Red Hat Certified Engineer            www.exceptionalminds.com
> Avalon Technology Group, Inc.         <><       (503) 246-3630
> >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
> >>>>This machine was last rebooted:  42 days 23:27 hours ago<<
> 
> _______________________________________________
> DB-SIG maillist  -  DB-SIG@python.org
> http://mail.python.org/mailman/listinfo/db-sig
> 

-- 
Thierry MICHEL

Nekhem Technologies France

thierry@nekhem.com
thierry@nekhem.fr
thierry@gnue.org

Agroparc
Batiment A
200, rue Michel de Montaigne
84911 AVIGNON Cedex 09

Tel: +33(0)490840154

"Sainthood in the Church of Emacs requires living a life of purity, 
but in the Church of Emacs, this does not require celibacy."
Richard Stallman.