Can't get LCHARVAR's with InformixDB

F

fhurley

I'm using the InformixDB package, which has been a real lifesaver, but
I'm finding I can't get any data from the Informix LCHARVAR types.
They're coming in as empty strings.

The cursor._description for the field in question is:
('msg_text', 'lvarchar', 0, 0, None, None, 1)

Appreciate any help... thanks.
 
C

Carsten Haese

I'm using the InformixDB package, which has been a real lifesaver, but
I'm finding I can't get any data from the Informix LCHARVAR types.
They're coming in as empty strings.

The cursor._description for the field in question is:
('msg_text', 'lvarchar', 0, 0, None, None, 1)

Appreciate any help... thanks.

What version are you using? I thought I fixed lvarchars a long time ago.

-Carsten
 
F

fhurley

Carsten said:
What version are you using? I thought I fixed lvarchars a long time ago.

2.2, with Python 2.4 on Windows... I installed via
InformixDB-2.2.win32-py2.4.exe

I can see the data with other tools... it's multi-line, stuff like
stack traces, etc., and many start with newlines... but whatever it is,
I'm consistently getting empty strings.
 
C

Carsten Haese

2.2, with Python 2.4 on Windows... I installed via
InformixDB-2.2.win32-py2.4.exe

Hm, this certainly warrants further investigation. I don't use lvarchars
myself, so it's possible that I did something that accidentally broke
the output binding for lvarchars.

Could you possibly send me a minimal test script that shows the problem?
Also, in case it matters, I'd like to know which versions of IDS and
CSDK or Informix Connect you're using.

Thanks,

Carsten.
 
F

fhurley

Carsten said:
Could you possibly send me a minimal test script that shows the problem?
Also, in case it matters, I'd like to know which versions of IDS and
CSDK or Informix Connect you're using.


Here's a sample script:

sql = '''select msg_tx from dev_log'''
import informixdb
conn = informixdb.connect('mydb')
cursor = conn.cursor()
cursor.execute(sql)
print 'description is <%s>' % cursor.description
print cursor.fetchall()

Output is:
description is <('msg_tx', 'lvarchar', 0, 0, None, None, 1)>
[('',), ('',), ('',), ('',), ('',), ('',)]

But one of them should be:
'''Something:SomethingElse - going for 221 possibilities [User:
HOST-NAME\XYZZY]:
Id OtherData
5878 C
5968 X
6732 V
[many more lines like this]
'''

Some hunting around, and I found this:

C:\Program Files\Informix\Client-SDK\bin>esql
IBM Informix CSDK Version 2.80, IBM Informix-ESQL Version 9.52.TC1

Not sure what IDS is... the Informix Server version is: 9.3 FC3,
according to the DBA guy.

Thanks much.
 
F

fhurley

Another thing...
Output is:
description is <('msg_tx', 'lvarchar', 0, 0, None, None, 1)>

The 0's worried me, as I could see where they could be used as parms to
allocate/trim things as necessary... just a thought.
 
C

Carsten Haese

Here's a sample script:

sql = '''select msg_tx from dev_log'''
import informixdb
conn = informixdb.connect('mydb')
cursor = conn.cursor()
cursor.execute(sql)
print 'description is <%s>' % cursor.description
print cursor.fetchall()

Thanks, but I can't use this to reproduce the problem. I'll need the
create table statement for dev_log.
Output is:
description is <('msg_tx', 'lvarchar', 0, 0, None, None, 1)>
[('',), ('',), ('',), ('',), ('',), ('',)]

But one of them should be:
'''Something:SomethingElse - going for 221 possibilities [User:
HOST-NAME\XYZZY]:
Id OtherData
5878 C
5968 X
6732 V
[many more lines like this]
'''

Some hunting around, and I found this:

C:\Program Files\Informix\Client-SDK\bin>esql
IBM Informix CSDK Version 2.80, IBM Informix-ESQL Version 9.52.TC1

Not sure what IDS is... the Informix Server version is: 9.3 FC3,
according to the DBA guy.

IDS = Informix Dynamic Server. The version numbers you gave me are what
I was looking for.

For what it's worth, I've tried a simple test script on my Linux server
that creates a temp table with an lvarchar column, inserts into it, and
reads from it, all without a problem. However, there are many
differences between my test environment and yours, and I'll need to know
your specific circumstances to isolate which difference is causing the
problem.

Thanks,

Carsten.
 
C

Carsten Haese

Another thing...


The 0's worried me, as I could see where they could be used as parms to
allocate/trim things as necessary... just a thought.

That is indeed a problem. For some as of yet undetermined reason, the
client thinks that msg_tx is a column of length zero, so it's no big
surprise that all you get back is empty strings. Once again, I'll need
the create table statement for the table you're selecting from in order
to investigate what's happening.

-Carsten
 
F

fhurley

Carsten said:
Once again, I'll need
the create table statement for the table you're selecting from in order
to investigate what's happening.

Here it is:

CREATE TABLE DEV_LOG(
LOG_ID SERIAL,
LEVEL VARCHAR (10),
POI_NM VARCHAR (255),
MSG_TX LVARCHAR(2000),
MSG2_TX LVARCHAR(5000)
) LOCK MODE ROW;

Thanks.
 
C

Carsten Haese

Here it is:

CREATE TABLE DEV_LOG(
LOG_ID SERIAL,
LEVEL VARCHAR (10),
POI_NM VARCHAR (255),
MSG_TX LVARCHAR(2000),
MSG2_TX LVARCHAR(5000)
) LOCK MODE ROW;

The following test script works fine for me:

---------------------------------------------------------
import informixdb

conn = informixdb.connect("mydb")
cur = conn.cursor()
cur.execute("""
CREATE temp TABLE DEV_LOG(
LOG_ID SERIAL,
LEVEL VARCHAR (10),
POI_NM VARCHAR (255),
MSG_TX LVARCHAR(2000),
MSG2_TX LVARCHAR(5000))""")
str1 = "ABCDEFGHIJ"*200
str2 = "ABCDEFGHIJ"*500
cur.execute("insert into dev_log values(?,?,?,?,?)",
(0,'MEDIUM','TESTMAN',str1,str2) )
cur.execute("select * from dev_log")
row = cur.fetchone()
assert row[3]==str1
assert row[4]==str2
print cur.description
---------------------------------------------------------

I have tested this two ways, once directly on the server on Linux, once
with a client-server connection from Windows to Linux. In both cases,
both lvarchars are being read back correctly. One notable difference
between your environment and mine is that I'm using CSDK version
2.90.TC3, which is more recent than the version of CSDK that you're
using.

I'd suggest upgrading to the newest version of CSDK. Please let me know
what happens after the upgrade.

-Carsten
 
F

fhurley

Carsten said:
I'd suggest upgrading to the newest version of CSDK. Please let me know
what happens after the upgrade.

That did the trick.... thanks very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top