forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Module rdb, rdb.dbapi2

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
voalp



Joined: 06 May 2019
Posts: 6

PostPosted: Fri Aug 30, 2019 1:49 pm    Post subject: Module rdb, rdb.dbapi2 Reply with quote

Hallo jfp

I am new to python.
I am very impressed about python and I am also very impressed about the potential using it on VMS.
I thank you very much bringing python to VMS --- very impressive

I tried to use the rdb and rdb.dbapi2
I studied your dbapi2.py implementation for rdb and I had to modify your
dbapi2.py source to use it.
Maybe I am wrong and I need your advice.

1. Using the executemany method in the cursor class results in the
error message like
Traceback (most recent call last):
File "test1.py", line 13, in <module>
[(123456,"H3TRAO"),(123457,"H3TRAO")])
File "/python_root/local/rdb/dbapi2.py", line 65, in executemany
self.stmt = Statement(operation)
NameError: global name 'Statement' is not defined

dbapi2.py line 65:
I changed the code from
self.stmt = Statement(operation)
to
self.stmt = rdb.Statement(operation)

2. I tried to use the start_read_only and start_read_write method in the connection class. I received the error Message
Traceback (most recent call last):
File "test1.py", line 5, in <module>
lza.start_read_write()
TypeError: start_read_write() takes no arguments (1 given)

dbapi2.p line 125
I changed the code from
def start_read_only():
to
def start_read_only(self):

and also line 130
def start_read_write():
to
def start_read_write(self):

-----------------------------------------------------------------------------------

Maybe I use the dapi2 in a wrong way so here is the code example for the above problems. ( KW_VD is a simple table consisting of BANDNR integer and MST char(10) )

import rdb
import rdb.dbapi2 as db2

lza = db2.Connection(database='MEWE_DB_LZA')
lza.start_read_write()
#lza.start_read_only()
cur = lza.cursor()
cur.execute("delete from kw_vd where bandnr in (123456,123457)");
# cur.execute("insert into kw_vd (bandnr,mst) values (123456,'H3TRAO');")
#cur.execute("insert into kw_vd (bandnr,mst) values (?,?);",
# (123456,"H3TRAO"))
cur.executemany("insert into kw_vd (bandnr,mst) values (?,?);",
[(123456,"H3TRAO"),(123457,"H3TRAO")])
cur.close()
lza.commit()
lza.close()

----------------------------------------------------------------------------------

Please advice
Thanks
Fritz
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 636

PostPosted: Fri Sep 06, 2019 8:47 am    Post subject: Reply with quote

Hello Fritz,

Your right,

Fixed, https://repos.sysgroup.fr/OpenVMS/vmspython/changeset/876c151f360acfe9e43dbaf73c4b3e72fd4aae64

Thanks for the update.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group