Hello list,

I've been working on a script to import data from .dbf (dBase IV)
files into postgres using SQLAlchemy.  I'm having issues with
importing a table that has "memo" fields, getting an error:  "can't
escape non-string object" when trying to insert() a dictionary with
the data in it.

This script has worked with other tables, so I'm not sure what's
wrong.  I'm using mxODBC on windows to access an ODBC DSN I set up to
handle the .dbf files.  I've created the following dictionary to map
mxODBC description types to SQLAlchemy types:

typedict = {'mxODBC':{1: String,  #'CHAR',
                      2: Numeric,  #'NUMERIC',
                      3: Numeric,  #'DECIMAL',
                      4: Integer,   #'INTEGER',
                      5: Integer, #'SMALLINT',
                      6: Numeric, #'FLOAT',
                      7: Numeric, #'REAL',
                      8: Numeric(20,2), #'DOUBLE',
                      9: Date, #'DATE',
                      10: Time, #'TIME',
                      11: DateTime, #'TIMESTAMP',
                      12: String, #'VARCHAR',
                      91: Date, #'TYPE_DATE',
                      92: Time, #'TYPE_TIME',
                      93: DateTime, #'TYPE_TIMESTAMP',
                      -1: Binary, #String, #'LONGVARCHAR',
                      -10: String, #'WCHAR_LONGVARCHAR',
                      -9: String, #'WCHAR_VARCHAR',
                      -8: String, #'WCHAR',
                      -7: Boolean, #'BIT',
                      -6: Integer, #'TINYINT',
                      -5: Integer, #'BIGINT',
                      -4: Binary, #'LONGVARBINARY',
                      -3: Binary, #'VARBINARY',
                      -2: Binary}, #'BINARY'

 ...so when I get a cursortype of -1 (LONGVARCHAR) I'm creating a
table that is using SQLAlchemy's Binary type.  When doing the insert,
then, I end up with the insert() trying to use data like this:

'fields': <psycopg2._psycopg.Binary object at 0x095F2728>

The reason I went with Binary in the first place was because I
couldn't use String and have a really large number for it's size (IIRC
it's limited to 255).

When doing the insert(), I'm just passing it a dictionary, and the
dictionary data is all unicode.

Any ideas on where I should look?

Brian

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to