I am using PyPyODBC to retrieve information from a HFSQL Database using the driver carring the same name.
If I retrieve two rows and one of them is composed of empty value, it will return the value from the previous row.
import pypyodbc
cnx = pypyodbc.connect("DRIVER={HFSQL};Server Name=URL.local;Server Port=4900; Database=b_database;UID=me;PWD=me2;IntegrityCheck=1")
cur = cnx.cursor()
cur.execute("select CODE_BLOCAGE from cws_table WHERE id in ('120140','66783')")
for row in cur.fetchall():
print('Two entries : 124140 and 66783')
print(row)
cur = cnx.cursor()
cur.execute("select CODE_BLOCAGE from cws_table WHERE id in ('66783')")
for row in cur.fetchall():
print('One entry : 66783')
print(row)
cur = cnx.cursor()
cur.execute("select CODE_BLOCAGE from cws_table WHERE id in ('120140')")
for row in cur.fetchall():
print('One entry : 120140')
print(row)
cnx.close()
Two entries : 124140 and 66783
('BLOCAGE',)
Two entries : 124140 and 66783
('BLOCAGE',)
One entry : 66783
('',)
One entry : 124140
('BLOCAGE',)
I tried the exact same driver using Powershell and I don't meet the issue:
$result =(new-Object Data.Odbc.OdbcCommand("SELECT CODE_BLOCAGE from cws_table WHERE id in ('120140','66783')",$conn)).ExecuteReader()
while ($result.Read()) {
$value = $result.GetValue(0)
Write-Output "New Line"
Write-Output $value
}
New Line
BLOCAGE RLM
New Line
The type of CODE_BLOCAGE is ctypes.c_wchar_Array_2048 and I think something incorrect happens with the buffer around line 1890 (PyPyODBC) where the value is already wrong. I guess that line 1880 or 1874 (driver call or for loop to browse columns) may be the source of my issue but I don't know how to debug this kind of driver/buffer
Could you please help me to find out where the value of the previous line is re-use while it shouldn't ?
Thank you, R