IBM / nzalchemy

Netezza database dialect for SQLAlchemy
Apache License 2.0
3 stars 7 forks source link

bindparams are not passed correctly #11

Open ArVar opened 3 years ago

ArVar commented 3 years ago

The statement

stmt = sql.text('select count(*) from _v_table where objid > 200000 and tablename = :name and schema = :schema')

ist processed to

'select count(*) from _v_table where objid > 200000 and tablename = ? and schema = ?'

which is transformed by nzpy to

'select count(*) from _v_table where objid > 200000 and tablename = NULL and schema = NULL`

This is the final statement which is executed. As a result the has_table method returns a wrong value, namely False instead True. Is this somehow an interference of nzpy and nzalchemy?

prajwalpatil2505 commented 3 years ago

Tried similar piece of code with bind parameters which is working fine.

engine = create_engine("netezza+nzpy://admin:password@localhost:5480/testpy")
conn = engine.connect()
stmt = text('select count(*) from _v_table where objid > 200000 and tablename = :name and schema = :schema')
result = conn.execute(stmt, name='TEST', schema='ADMIN')

Output:

$ python3 nzpyparam.py
count: 1

Query is processed in below order(from logs): select count(*) from _v_table where objid > 200000 and tablename = NULL and schema = NULL

select count(*) from _v_table where objid > 200000 and tablename = \'TEST\' and schema = \'ADMIN\'

Could you please elaborate issue you are facing and provide sample application with logs for further investigation.