[egenix-users] "right truncation" warning in mx.ODBC.Windows

M.-A. Lemburg mal at egenix.com
Thu Mar 11 11:29:41 CET 2004


Charles Bearden wrote:
> I'm using mx.ODBC version 2.0.1 (that's the version in
> site-packages\mx\ODBC\ODBC.py; the "commercial" download file is version
> 2.0.6) with ActivePython 2.3.2 Build 230 to talk to a MS SQL Server.  I
> am having a puzzling right truncation problem when trying to insert even
> small values into a table.  In order to isolate variables, I am
> inserting values into only required (non-NULL) fields.  INSERTing the
> same values into the table works via Query Analyzer.  Here is sample
> code, traceback, & the table definition.  Any ideas on how to make this
> work would be greatly appreciated--thanks in advance!
> 
> --------------------------begin snippet-----------------------------
> import time
> from mx.ODBC.Windows import DriverConnect
> import mx.DateTime
> 
> con = DriverConnect("DSN=theDb;UID=theUser;PWD=thePwd")
> cur = con.cursor()
> 
> datestmp = mx.DateTime.localtime(time.time())

Try to use a string here: '2004-03-11 10:00:00' and
see whether that makes any difference (the ODBC driver could
be having trouble with the seconds fraction - even though
we've never heard of such problems with SQL Server before).

> val_t = (10073787, 0, datestmp, 1)
> 
> ins_stmnt = '''
>   INSERT INTO pmLinkHistory
>   ('PMID', 'Ord', 'LastActionDate', 'LastAction')
>   VALUES
>   (?, ?, ?, ?)
> '''
> cur.execute(ins_stmnt, val_t)
> con.close()
> 
> -------------------------begin traceback----------------------------
> 
> Traceback (most recent call last):
>   File "./simpletest.py", line 18, in ?
>     cur.execute(ins_stmnt, val_t)
> mxODBC.Warning: ('22001', 0, '[Microsoft][ODBC SQL Server Driver]String
> data, right truncation', 4579)
> 
> -------------------------begin table def----------------------------
> 
> CREATE TABLE [dbo].[pmLinkHistory] (
>         [ID] [int] IDENTITY (1, 1) NOT NULL ,
>         [PMID] [int] NOT NULL ,
>         [Ord] [smallint] NOT NULL ,
>         [LastActionDate] [datetime] NOT NULL ,
>         [LastAction] [smallint] NOT NULL ,
>         [Info] [nvarchar] (24) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
> ,
>         [Url] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CS_AS
> NULL ,
>         [LinkName] [nvarchar] (256) COLLATE SQL_Latin1_General_CP1_CS_AS
> NULL ,
>         [Provider] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CS_AS
> NULL ,
>         [Notes] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CS_AS
> NULL
> ) ON [PRIMARY]
 >
> --------------------------end table def-----------------------------
> (The table also has a normal primary key comprising PMID and Ord.  No
> other indices, triggers, or stored procedures.)
> 
> 
> Chuck Bearden
> Systems Analyst III
> School of Health Information Sciences
> University of Texas at Houston
> 713.500.3954 (voice)
> 713.500.3907 (fax)
> Charles.F.Bearden at uth.tmc.edu
>  
> 
> 
> _______________________________________________________________________
> eGenix.com User Mailing List                     http://www.egenix.com/
> http://lists.egenix.com/mailman/listinfo/egenix-users

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Mar 11 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
EuroPython 2004, Göteborg, Sweden                           87 days left

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::



More information about the egenix-users mailing list