On 2007-10-24 21:36, Lukasz Szybalski wrote: > On 10/19/07, Lukasz Szybalski <[EMAIL PROTECTED]> wrote: >> Hello, >> I have a python program that converts some data and writes it via ODBC >> driver. >> I am using a win32 dbi,odbc to do that. (none of the free other ones work) >> >> I just upgraded my ODBC driver to a newer version that supposedly is a >> 2.0 compatible. >> >> Now I am getting a: >> dbi.no-error: [SoftVelocity Inc.][TopSpeed ODBC Driver]String or >> binary data would be truncated in EXEC >> > This error means that truncation would have to happen, so instead of > truncating the data the odbc driver decided to throw an error and exit > the program. > > Are truncation errors suppose to stop the write of data per API 2.0 > specifications?
Well, yes. You hardly want data to be truncated while transferring it from or to the database. > I have tried the ceODBC and the new version that will come out will > support the TopSpeed ODBC Driver 5.0 for tps data files. > > Also, as a side not. If you ever come around a "Driver not capable" > error you need to set the autocommit=True. > > c = ceODBC.Connection("DSN=MYDATASOURCE", autocommit = True) While most file-based ODBC drivers require (re)enabling auto-commit, you should be aware that by doing so, you risk data corruption if you write to the data source and find an error in the processing halfway through. Transaction based programming saves you from this. >> What I noticed is that dbi.no-error has given me this error. How do I >> except a 'no-error' error? > And if you need to except any errors from database: > > except ceODBC.DatabaseError, e: > print e > #do stuff Right. DatabaseError is the base class of all database interface related errors as per the DB-API 2.0. This is true for all DB-API 2.0 compatible database modules. BTW: I wonder why SoftVelocity describes an ODBC driver that "conforms to the ODBC 1 specification with many Level 2 features" as "new": http://www.softvelocity.com/products/database_tsodbc.htm The ODBC standard has already reached version 3.51 many years ago. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 25 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig