mmoiseenko / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

1 character text column values are read incorrectly #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
python 2.7
windows 32 bit
pypyodbc version: 0.6
connection via user DSN to remote microsoft sql server

symptoms:
all works except database text fields of length 1 are read as having value 
equal to empty string when they in fact have valid one character values.

example: code below (with correct database tables) shows this problem. The code 
works fine with pyodbc, symptom as above when swapped to pypyodbc

import pprint from pprint
import pypyodbc as pyodbc

# eep.categ and eep.status are colums typed as
# text
# field size 1
test_sql = """SELECT eep.eeid, eep.namei,eep.categ, eep.status
            FROM ((eedbo.eep LEFT JOIN eedbo.Ug ON eep.eeid=Ug.Ueeid)
            LEFT JOIN eedbo.Phd ON eep.eeid=Phd.Peeid)
            LEFT JOIN eedbo.MSc ON eep.eeid=MSc.Meeid
            WHERE (eep.Namei LIKE 'Bal%') and (eep.Status = 'F') and (eep.Categ = 'U');"""

def read_odbc():
        cnxn = pyodbc.connect('DSN=sqlserver;Trusted_Connection=yes')
        cursor = cnxn.cursor()
        cursor.execute(sql)
        rows = cursor.fetchall()
        for row in rows:
            pprint(row)

Original issue reported on code.google.com by clarke...@gmail.com on 15 Jul 2012 at 12:25

GoogleCodeExporter commented 8 years ago
Further info. The object used by pypyodbc to hold column data for these bad 
columns is:
ctypes.c_wchar_Array_2

Original comment by clarke...@gmail.com on 15 Jul 2012 at 12:39

GoogleCodeExporter commented 8 years ago
Hi, how did you define the text field, is it varchar(1)? I can not reproduce 
the symptom.

Original comment by jiangwen...@gmail.com on 18 Jul 2012 at 2:08

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 23 Jul 2012 at 12:22

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 28 Jul 2012 at 2:24

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 28 Jul 2012 at 8:43

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 23 Mar 2013 at 11:40