× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have pyodbc installed and I wrote a simple SELECT a few weeks ago to "kick the tires". That worked fine. Today I tried to convert an existing script to use pyodbc. It does an INSERT that runs fine on Windows but on IBMi it fails with:
Error('01004', '[01004] [IBM][System i Access ODBC Driver]String data right truncation. (30016) (SQLExecDirectW)')

If it's valid on Windows, I can't see why it fails on IBMi.



-----Original Message-----
From: John Yeung [mailto:gallium.arsenide@xxxxxxxxx]
Sent: Thursday, August 01, 2019 9:36 AM
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxxxxxxxx>
Subject: [IBMiOSS] Trouble with numeric columns in pyodbc

I am having severe issues with pyodbc in PASE.

Let's say TESTFILE is a table with four columns, TFLD01, TFLD02, TFLD03, and TFLD04, all numeric. I've tried the following from both my PC and PASE:

# begin snippet
import pyodbc

conn = pyodbc.connect(<my connection stuff here>)
c1 = conn.cursor()

c1.execute('''
insert into testfile values (?, ?, ?, ?)
''', (1, 2, 3, 4))
c1.execute('''
insert into testfile values (?, ?, ?, ?)
''', ('2', '4', '6', '8'))
# end snippet

From my PC, both rows are successfully inserted. The second row is
implicitly converted to numeric values.

From PASE, it's a disaster. The first row is silently inserted as all
zeros (the columns are not null-capable; had they been, I suppose the row might have consisted of nulls), and the second row raises the following exception:

pyodbc.DataError: ('22018', '[22018] [IBM][System i Access ODBC
Driver][DB2 for i5/OS]SQL0406 - Conversion error on assignment to column TFLD01. (-406) (SQLExecDirectW)')

Is anyone else experiencing this? In its current state, at least on my machine, obviously pyodbc is unusable from PASE. :(

John Y.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.