Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nzpy: exception is not reset on repeated execution #6

Closed
shabbir10july opened this issue Sep 2, 2020 · 1 comment
Closed

nzpy: exception is not reset on repeated execution #6

shabbir10july opened this issue Sep 2, 2020 · 1 comment
Assignees

Comments

@shabbir10july
Copy link
Contributor

shabbir10july commented Sep 2, 2020

Repro steps. Create schema as outlined below. then execute couple of statements through nzsql - 1st will fail, while 2nd will succeed.

DEV.ADMIN(ADMIN)=> create table t1(c1 int, c2 varchar(10)); CREATE TABLE DEV.ADMIN(ADMIN)=> insert into t1 values(1, 'one'); INSERT 0 1 DEV.ADMIN(ADMIN)=> select * from t1; 
C1 | C2
----+-----
1 | one
(1 row)


DEV.ADMIN(ADMIN)=> select c3 from t1;
ERROR: Attribute 'C3' not found 
DEV.ADMIN(ADMIN)=> select c2 from t1; 
C2
-----
one
(1 row)

However, when executing these 2 statements in the same order via nzpy, the same error displayed twice. Here is the code sample and the output:

import nzpy
con = nzpy.connect(user='admin', password='password', port=5480, database='dev')
cur = con.cursor() 
stmts = [
 "select c2 from t1",
 "select c3 from t1",
]
for i, s in enumerate(stmts, 1): 
try: 
 cur.execute(s)
 out = cur.fetchall()
except Exception as e:
 print("I={}; Error={}".format(i, str(e)))
cur.close()
Output:
/workspaces/elog/main/src/tests/json> python3 testCon.py
I=1; Error=ERROR: Attribute 'C3' not found
I=2; Error=ERROR: Attribute 'C3' not found
@shabbir10july
Copy link
Contributor Author

This is fixed in http://github.com/IBM/nzpy/pull/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant